//获取应用实例
var app = getApp();
Page({
    data: {
        //处理订单
        orderStatusDoingText:"处理订单",
        orderStatusFinishText:"订单完成",
        orderStatusClass: "icon_end",
        orderStatusAdd: "icon_doing",
        orderStatusToAdd: "icon_end",
        orderStatusTextClass: "",
        orderStatusExplainClass: "icon_order_succeed",
        orderStatusLineColour: "",
        "isShowFootNav": false,
		    statusName: "",
		    statusDescDetail: "",
		    orderTitle: "",
		    totalServiceAmount: "",
		    orderAmount: "",
		    eOrderAddress: "",
		    processTitle: "",
		    orderId: "",
        isShowPage:true  //显示页面
    },

    onLoad: function (option) {
        var orderId = option.orderId;
        var pageObj = this;
        var opt = {
            url: app.globalData.host+"/wx/etw/detail.ajax",
            data: {
                'orderId': orderId
            },
            sucFn:function (result) {
            	var res = result.body;
                pageObj.setData({
	                orderStatusExplainTextClass_f: res.status==3|| res.status==4|| res.status==5?'font-color-red':'',
	                orderStatusExplainClass: res.status==3|| res.status==4|| res.status==5?'icon_oeder_close_off':'icon_order_succeed',
                  isShowPage: true,
                  statusName: res.statusName,
                  statusDescDetail: res.statusDescDetail,
                  orderTitle: res.orderTitle,
	                serviceFee: res.serviceFee,
	                needInvoice: res.needInvoice==1?'（已申请发票）':'',
	                endorseFee: res.endorseFee,
	                payAmount: res.payAmount,
	                eOrderAddress: res.address,
	                processTitle: res.processlist[0].name,
	                processTime: app.toYMDHMSDate(res.processlist[0].createTime),
	                orderId: res.orderId,
	                timesName: res.timesName,

	                payType: res.payType==2?'支付宝':res.payType==3?'微信':'',
	                payNo: res.payNo,
	                createTime: app.toYMDHMSDate(res.createTime),
	                payTime: app.toYMDHMSDate(res.payTime),
	                data: res,

	                expressNbr: res.expressNbr,
	                acceptanceNbr: res.acceptanceNbr,

	                completeText: res.status==4?'关闭时间':res.status==8?'完成时间':'',
	                completeTime: app.toYMDHMSDate(res.completeTime),
	                completeTimeIsShow: res.completeTime?true:false

                });
                switch (result.body.status) {   //result.body.status
	                /*
	                 * style.icon_success      成功绿色大圆
	                 * style.icon_error        失败红色大圆
	                 * style.icon_moren_error  失败红色中圆
	                 * style.icon_moren        默认灰色中圆
	                 *
	                 * bg-color_blue 蓝色背景
	                 * bg-color_red  红色背景
	                 * */
	                case 0:
		                pageObj.setData({
			                orderStatusTwoText:"处理订单",
			                orderStatusThreeText:"订单完成",

			                orderStatusOne: "icon_doing",
			                orderStatusTwo: "",
			                orderStatusThree: "",

			                orderSideOneLineColour: "",
			                orderSideTwoLineColour: "",
			                orderSideThreeLineColour: "",

			                orderStatusTwoTextColour: "",
			                orderStatusThreeTextColour: ""

		                });
		                break;

	                case 1:
		                pageObj.setData({
			                orderStatusTwoText:"处理订单",
			                orderStatusThreeText:"订单完成",

			                orderStatusOne: "icon_doing",
			                orderStatusTwo: "icon_doing",
			                orderStatusThree: "",

			                orderSideOneLineColour: "bg-color-blue",
			                orderSideTwoLineColour: "bg-color-blue",
			                orderSideThreeLineColour: "",

			                orderStatusTwoTextColour: "font-color-blue",
			                orderStatusThreeTextColour: ""

		                });
		                break;

	                case 2:
		                pageObj.setData({
			                orderStatusTwoText:"处理订单",
			                orderStatusThreeText:"订单完成",

			                orderStatusOne: "icon_doing",
			                orderStatusTwo: "icon_doing",
			                orderStatusThree: "",

			                orderSideOneLineColour: "bg-color-blue",
			                orderSideTwoLineColour: "bg-color-blue",
			                orderSideThreeLineColour: "",

			                orderStatusTwoTextColour: "font-color-blue",
			                orderStatusThreeTextColour: ""

		                });
		                break;
	                case 3:
		                pageObj.setData({
			                orderStatusTwoText:"办理失败",
			                orderStatusThreeText:"订单完成",

			                orderStatusOne: "icon_doing",
			                orderStatusTwo: "icon_fail",
			                orderStatusThree: "",

			                orderSideOneLineColour: "bg-color-blue",
			                orderSideTwoLineColour: "bg-color-blue",
			                orderSideThreeLineColour: "",

			                orderStatusTwoTextColour: "font-color-red",
			                orderStatusThreeTextColour: ""

		                });
		                break;
	                case 4:
		                pageObj.setData({
			                orderStatusTwoText:"办理失败",
			                orderStatusThreeText:"订单关闭",

			                orderStatusOne: "icon_doing",  //成功大圆
			                orderStatusTwo: "icon_failed", //失败中圆
			                orderStatusThree: "icon_fail",  //失败的大圆

			                orderSideOneLineColour: "bg-color-blue",
			                orderSideTwoLineColour: "bg-color-blue",
			                orderSideThreeLineColour: "bg-color-red",

			                orderStatusTwoTextColour: "font-color-red",
			                orderStatusThreeTextColour: "font-color-red"

		                });
		                break;

	                case 5:
		                pageObj.setData({
			                orderStatusTwoText:"办理失败",
			                orderStatusThreeText:"订单已失效",

			                orderStatusOne: "icon_doing",  //成功大圆
			                orderStatusTwo: "icon_failed", //失败中圆
			                orderStatusThree: "icon_fail",  //失败的大圆

			                orderSideOneLineColour: "bg-color-blue",
			                orderSideTwoLineColour: "bg-color-blue",
			                orderSideThreeLineColour: "bg-color-red",

			                orderStatusTwoTextColour: "font-color-red",
			                orderStatusThreeTextColour: "font-color-red"

		                });
		                break;
	                case 8:
		                pageObj.setData({
			                orderStatusTwoText:"处理订单",
			                orderStatusThreeText:"订单完成",

			                orderStatusOne: "icon_doing",  //成功大圆
			                orderStatusTwo: "icon_doing", //失败中圆
			                orderStatusThree: "icon_doing",  //失败的大圆

			                orderSideOneLineColour: "bg-color-blue",
			                orderSideTwoLineColour: "bg-color-blue",
			                orderSideThreeLineColour: "bg-color-blue",

			                orderStatusTwoTextColour: "font-color-blue",
			                orderStatusThreeTextColour: "font-color-blue"

		                });
		                break;

                }
            }
        };
        app.ajax(opt);
    },
    onHide:function () {
    },

	  toUrl: function () {
		  app.setStorageSync(app.globalData.twPassCache,this.data.data)
		  app.navigateTo({url:'../twPassInformation/twPassInformation?type='+'enCode'})
	  },

    progressTap:function(e){
        var orderId = e.target.dataset.id;
        app.navigateTo({
            url: '../twProgress/twProgress?orderId='+orderId
        });
    }
});
